﻿<%
    page route "/";

    using System;
    using System.IO;
    using System.Linq;
    using System.Diagnostics;
    using NetFluid;
    using System.Collections.Concurrent;
	using MongoDB.Driver;
	using MongoDB.Driver.Builders;

    static string[] colors;

    Stopwatch stopwatch;
    stopwatch=new Stopwatch();
    stopwatch.Start();

    public override void OnServerStart()
    {
        colors = new[]{"#F3A01E", "#9DC425", "#4B8DB5", "#7C48B5", "#A75375", "#D05D2A"};
    }

    public string rand_color()
    {
        return colors[rnd(colors.Length-1)];
    } 
%>

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=620" />
        
        <title>NetFluid</title>

        <link rel="stylesheet" href="/style.css" type="text/css" />
        <script type="text/javascript" src="/jquery.js"></script>
        <script type="text/javascript" src="/jqueryui.js"></script>
        
        <script type="text/javascript" src="/tiny_mce.js"></script>
        <script type="text/javascript" src="/jquery.tinymce.js"></script>

        <script type="text/javascript" src="/jquery.form.js"></script>
        <script type="text/javascript" src="/jquery.validate.js"></script>
        <script type="text/javascript" src="/jquery.tools.js"></script>

        <script language="javascript" type="text/javascript" src="/jquery.flot.js"></script>

        <script type="text/javascript" src="my.js"></script>

    </head>
	<body>
        <script type="text/javascript"> $(setup); </script>
        <div id="main">
            <header>
                <nav>
                    <ul>
                        <li>
                            <a href="/"><h1>Netfluid</h1></a>
                        </li>
                        <li>
                            <a href="/download"><h2>Download</h2></a>
                        </li>
                        <li>
                            <a href="/documentation"><h2>Documentation</h2></a>
                        </li>
                        <li>
                            <a href="/tutorials"><h2>Tutorials</h2></a>
                        </li>
                        <li>
                            <a href="/faq"><h2>Faq</h2></a>
                        </li>
                        <li>
                            <a href="/assistance"><h2>Assistance</h2></a>
                        </li>
                        <li>
                            <a href="/business"><h2>Business</h2></a>
                        </li>
                        <li>
                            <a href="/projects"><h2>Projects</h2></a>
                        </li>
                    </ul>
                </nav>
            </header>
            <div id="container">
                %define Body
                    <div style="text-align:right;padding-right:20px;">
                        <form action="." method="get">
                            <label><h2>Search:</h2></label><input name="q" type="text" size="32" /><input type="submit" value="Go" />
                        </form>
                    </div>
                    <div>
                        <h2>Discover why NetFluid is the fastest server side language in the world</h2>
                        <div>
                            Antani Antani Antani Antani Antani Antani Antani Antani Antani Antani Antani Antani Antani Antani Antani Antani Antani Antani Antani Antani Antani Antani Antani Antani Antani Antani Antani Antani Antani Antani 
                        </div>
                    </div>
                    %var user=session("User");
                    <div>
                            %if(user==null)
                                Membership <a href="signin">sign in</a>-<a href="signup">sign up</a>
                            %else
                                {%user.NiceName%}
                            %end if
                    </div>
                    <br style="clear:both"/>
                    <div class="separator"></div>
                    %foreach(var news in Database.News.FindAll().Take(20))
                        <span class="box" style="background-color:{% rand_color() %}">
                            <a href="/{%news.Link.UrlEncode()%}">
                                <h3>
                                    %if(news.Title.Length<=32)
                                        {%news.Title%}
                                    %else
                                        {%news.Title.Substring(0,32)%}
                                    %end if
                                </h3>
                                <span>
                                    %if(news.Body!=null)
                                        % var preview = news.Body.StripHTML();
                                        % preview = preview.Length<=250 ? preview : preview.Substring(0,250);
                                        {%preview%}
                                    %else
                                        preview unavailable
                                    %end if
                                </span>
                            </a>
                        </span>
                    %end for
                %end define

                %Body();

                <%
                    stopwatch.Stop();

                    //Ticks / Ticks per Secondo = secondi
                    //secondi * 1000 = millisecondi
                    //1000 millisecondi / millisecondi pagina = pagine al secondo

                    var elapsed  = (((decimal)stopwatch.ElapsedTicks)/Stopwatch.Frequency)*1000;
                    var pages = 1000/elapsed;
                %>
                <div class="performance">
                    Page served in {% elapsed.ToString("0.##") %} milliseconds ({% decimal.Truncate(pages) %} pages per second)
                </div>
            </div>
            <footer>
                <div class="copyright">&copy;2009 - 2012 Matteo Fabbri</div>
                <div class="license">
                    <a rel="license" class="external" href="http://creativecommons.org/licenses/by-nc-nd/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-nd/3.0/88x31.png" /></a><br /><span xmlns:dct="http://purl.org/dc/terms/" href="http://purl.org/dc/dcmitype/InteractiveResource" property="dct:title" rel="dct:type">NetFluid</span> by <a class="external" xmlns:cc="http://creativecommons.org/ns#" href="http://www.netfluid.com" property="cc:attributionName" rel="cc:attributionURL">NetFluid</a> is licensed under a <a class="external" rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License</a>.
                </div>
                <div>
                    <a href="contact">Contact</a> - <a href="admin">Admin</a>
                </div>
            </footer>
        </div>
	</body>
</html>
